package com.qboot.quartz.job;

import lombok.extern.slf4j.Slf4j;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

/**
 * 创建测试任务
 *
 * @author Tellsea
 * @date 2023/2/14
 */
@Slf4j
@Component
public class TestJob extends QuartzJobBean {

    @Override
    protected void executeInternal(JobExecutionContext context) {
        log.info("定时任务开始执行：" + this.getClass().getSimpleName());
        // 获取参数
        JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
        jobDataMap.remove("jobInfo");
        // 业务逻辑 ...
        jobDataMap.entrySet().forEach(temp -> System.out.println("任务参数：" + temp.getKey() + " : " + temp.getValue()));
    }
}
